﻿@model IEnumerable<ArivisTests.Models.TestCase>
@using ArivisTests.Views;

@functions {
    MvcHtmlString Wikify(ArivisTests.Models.TestCase testcase, string url)
    {
        var sb = new System.Text.StringBuilder();
        sb.Append("||");
        sb.AppendFormat("[{0} {1}]", url, testcase.Name);
        sb.Append("||");
        if (testcase.User != null)
            sb.Append(testcase.User.UserName);
        sb.Append("||");
        if (testcase.Result != null)
            sb.Append(testcase.Result.Name);
        sb.Append("||");
        if (testcase.Comment != null)
            sb.Append(testcase.Comment.Replace("\r\n","[[br]]"));
        if (testcase.Comment != null && testcase.Tickets != null)
            sb.Append("[[br]]");
        if (testcase.Tickets != null)
            sb.Append(testcase.Tickets.Replace("\r\n","[[br]]"));
        sb.Append("||");
        sb.AppendLine();
        return MvcHtmlString.Create(sb.ToString());
    }
}

<textarea readonly="readonly" rows="20" cols="120" style="border:1px solid gray; margin:0.5em; padding:0.5em; background-color:#eee; font-size: 9pt; font-family:monospace; width:auto;">
||=Test =||=Tester =||=Result =||=Comment, Tickets =||
@foreach (var testcase in Model.Where(x => x.Result != null).OrderBy(x => x.Result))
{
@Wikify(testcase, Url.Action("Details", "TestCase", new { id = testcase.Id}, Request.Url.Scheme))
}
</textarea>
